package test;

import java.io.IOException;
import java.util.*;

public class test {
    static Set set = new HashSet();
    static Set set1=new HashSet();

    static List li=new ArrayList();
    static List li1=new ArrayList();
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
       while (true){
           System.out.println("1)开始抽题");
           System.out.println("2)结束抽题");
           int select=sc.nextInt();
           switch (select){
               case 1:
                   ct(sc);
           set = new HashSet();
           set1 = new HashSet();
                   break;
               case 2:
                   return;
           }
       }
    }

    private static void ct(Scanner sc) {
        System.out.println("请输入抽查的人数");
        int stu= sc.nextInt();
        System.out.println("请输入抽查的题数");
        int ti= sc.nextInt();
        read r=new read();


        try {
            ArrayList<Student> students = r.AdTi2();
            ArrayList<Title> titles = r.AdTi1();
            for (int j=0;j<stu;j++){
                int i = (int) (Math.random()*students.size());
                for (int w=0;w<li.size();w++){
                    if (li.contains(students.get(i))){
                       w--;
                   }
                    li.add(students.get(i));
                    set.add(students.get(i));
                }

            }
            System.out.println(set.toString());
            for (int k=0;k<ti;k++){
                int t= (int) (Math.random()*titles.size());
                if (set1.contains(titles.get(t))){
                    k--;
                }
                set1.add(titles.get(t));
            }
            System.out.println(set1.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return;
    }
}
